const JWT = require('jsonwebtoken')
const serect="serect"//秘钥
const expiresIn="6h"//有效期6个小时

/*加密生成token
*random为随机参数，保证加密生成token随机性
*/
const JWTgetToken = (payload,pram={}) => {
    const { Fserect,FexpiresIn } = pram
    return JWT.sign({ ...payload, random: Date.now() }, Fserect||serect, { expiresIn:FexpiresIn||expiresIn })
}

const JWTgetInfo = (token,Fserect) => {
    return JWT.verify(token,Fserect||serect)
}

module.exports = {JWTgetToken, JWTgetInfo}